<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/6/19
 * Time: 14:49
 */
namespace App\Admin\Controllers;

use App\Admin\Models\AdminUser;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class LoginController extends Controller {
    public function login() {
        return view('login.login');
    }

    public function dologin(Request $request) {
        $user = $request->has('name')?$request->input('name'):'';
        $password = $request->has('pwd')?$request->input('pwd'):'';
        if(!$user||!$password) {
            return response()->error('PARAM_EMPTY');
        }
        $password = md5($password);
        $user = AdminUser::judgeLogin($user,$password);
        if($user) {
            $request->session()->put('uid', $user->id);
        }
        return response()->success();
    }

}